const router = require('koa-router')()
const fs=require('fs')
// var page=fs.readFileSync('E:\Node.js应用开发\Node.js实例\实验（十三）KOA\project-name\chapter.html')
router.get('/', async (ctx, next) => {
  var list=[
    {
      chapterName:"zhangsan",
      publishTimer:20,
      author:'wmm',
      views:'views'
    },
    {
      chapterName:"zhangsan",
      publishTimer:20,
      author:'wmm',
      views:'views'
    }
  ]
  await ctx.render("index",{list:list})
  // await ctx.render('index', {
  //   title: 'Hello Koa 2!'
  // })
})

router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

module.exports = router
